#ifndef BINARYFILE_H
#define BINARYFILE_H

#include <QObject>
#include <QWidget>
#include <QStringList>
#include "enumtypes.h"

class QSpinBox;
class QCheckBox;
class QComboBox;
class QFormLayout;

class BinaryFile : public QObject
{
    Q_OBJECT

public:
    BinaryFile();

    void readFile();

    QString filePath;
    QString fileName;
    int numDatas;
    int numTemporalLayers;
    int numSpatialDimensions;
    bool isRegular;
    int numSpatialPoints;           // only used when data is irregularly distributted
    int numSpatialPointsAlongAxis1; // only used when data is regularly distributted
    int numSpatialPointsAlongAxis2;
    int numSpatialPointsAlongAxis3;
    EnumTypes::DataType dataType;
    QStringList dataNameList;
    QList<float> *data_float;
    QList<double> *data_double;
    QList<qint32> *data_qint32;
    QList<qint64> *data_qint64;
};

class BinaryDataFormatUI : public QWidget
{
    Q_OBJECT

public:
    BinaryDataFormatUI(QWidget *parent = 0);

    void setFrom(const BinaryFile &binaryFile);
    void setTo(BinaryFile *binaryFile);
    void disable();
    void enable();

protected slots:
    void setSpatialPointsMode(bool flag);

public:
    QFormLayout *layout;
    QSpinBox *spinBox_numDatas;
    QSpinBox *spinBox_numTemporalLayers;
    QSpinBox *spinBox_numSpatialDimensions;
    QCheckBox *checkBox_isRegular;
    QSpinBox *spinBox_numSpatialPoints;
    QSpinBox *spinBox_numSpatialPointsAlongAxis1;
    QSpinBox *spinBox_numSpatialPointsAlongAxis2;
    QSpinBox *spinBox_numSpatialPointsAlongAxis3;
    QComboBox *comboBox_dataType;
};

#endif // BINARYFILE_H
